package com.binest.investDetails.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.investDetails.domain.InvestDetails;
import com.binest.investDetails.service.IInvestDetailsService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 投资详情Controller
 * 
 * @author binest
 * @date 2024-01-18
 */
@RestController
@RequestMapping("/investDetails")
public class InvestDetailsController extends BaseController
{
    @Autowired
    private IInvestDetailsService investDetailsService;

    /**
     * 查询投资详情列表
     */
    @PreAuthorize("@ss.hasPermi('investDetails:investDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(InvestDetails investDetails)
    {
        startPage();
        List<InvestDetails> list = investDetailsService.selectInvestDetailsList(investDetails);
        return getDataTable(list);
    }

    /**
     * 导出投资详情列表
     */
    @PreAuthorize("@ss.hasPermi('investDetails:investDetails:export')")
    @Log(title = "投资详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvestDetails investDetails)
    {
        List<InvestDetails> list = investDetailsService.selectInvestDetailsList(investDetails);
        ExcelUtil<InvestDetails> util = new ExcelUtil<InvestDetails>(InvestDetails.class);
        util.exportExcel(response, list, "投资详情数据");
    }

    /**
     * 获取投资详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('investDetails:investDetails:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(investDetailsService.selectInvestDetailsById(id));
    }

    /**
     * 新增投资详情
     */
    @PreAuthorize("@ss.hasPermi('investDetails:investDetails:add')")
    @Log(title = "投资详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvestDetails investDetails)
    {
        return toAjax(investDetailsService.insertInvestDetails(investDetails));
    }

    /**
     * 修改投资详情
     */
    @PreAuthorize("@ss.hasPermi('investDetails:investDetails:edit')")
    @Log(title = "投资详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvestDetails investDetails)
    {
        return toAjax(investDetailsService.updateInvestDetails(investDetails));
    }

    /**
     * 删除投资详情
     */
    @PreAuthorize("@ss.hasPermi('investDetails:investDetails:remove')")
    @Log(title = "投资详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(investDetailsService.deleteInvestDetailsByIds(ids));
    }
}
